﻿Imports System.Diagnostics.Contracts
Imports FTTK.Json

Namespace FTTK.Services.Interfaces.Rest
    ''' <summary>
    ''' Defines the JsonPareser interface.
    ''' </summary>
    ''' <remarks></remarks>
    <ContractClass(GetType(JsonParserContract))>
    Public Interface IJsonParser

        ''' <summary>
        ''' Parses the input string into single Json object.
        ''' </summary>
        ''' <param name="jsonString">The json string.</param>
        ''' <remarks></remarks>
        Function ParseIntoSingleObject(jsonString As String) As JsonObject

        ''' <summary>
        ''' Parses the input string into array Jsonobjects.
        ''' </summary>
        ''' <param name="jsonString">The json string.</param>
        ''' <remarks></remarks>
        Function ParseIntoArrayObjects(jsonString As String) As IEnumerable(Of JsonObject)
    End Interface

    <ContractClassFor(GetType(IJsonParser))>
    Friend Class JsonParserContract
        Implements IJsonParser

        Public Function ParseIntoArrayObjects(jsonString As String) As System.Collections.Generic.IEnumerable(Of Json.JsonObject) Implements IJsonParser.ParseIntoArrayObjects
            Contract.Requires(Of ArgumentNullException)(Not String.IsNullOrEmpty(jsonString), "jsonString must be not null")
            Throw New NotImplementedException()
        End Function

        Public Function ParseIntoSingleObject(jsonString As String) As Json.JsonObject Implements IJsonParser.ParseIntoSingleObject
            Contract.Requires(Of ArgumentNullException)(Not String.IsNullOrEmpty(jsonString), "jsonString must be not null")
            Throw New NotImplementedException()
        End Function
    End Class

End Namespace